package model;
/**
 * ValueDependency is a card that might deposit money, depending on the value of all your assets.
 * @author Group 20
 *
 */
public class ValueDependency extends Income
{
	/**
	 * maxBalance is the integer for the maximum value of assets you can have while still getting the bonus.
	 * valueOfAssets is the combined value of your assets except your balance.
	 */
	private int maxBalance, valueOfAssets;
	
	/**
	 * Constructor
	 * @param description: Card description
	 * @param amount: value for amount
	 * @param maxBalance: maximum balance to receive bonus
	 */
	public ValueDependency(String description,int amount, int maxBalance) {
		super(description, amount);
		this.maxBalance = maxBalance;
	}

	/**
	 * Sets the valueOfAssets
	 * @param valueOfAssets
	 */
	public void setValueOfAssets(int valueOfAssets) {
		this.valueOfAssets = valueOfAssets;
	}

	/**
	 * Calculates if you will get the bonus
	 */
	@Override
	protected int calculateIncome(int balance) {
		if(balance+valueOfAssets <= maxBalance)
		{
			payment = amount;
			return amount;
		}
		else
		{
			payment = 0;
			return 0;
		}
	}

	/**
	 * toString Method
	 */
	@Override
	public String toString() {
		return "ValueDependency [maxBalance=" + maxBalance + super.toString() +"]";
	}
}
